home *** CD-ROM | disk | FTP | other *** search
- Path: sun001.spd.dsccc.com!spd!jmccarty
- From: jmccarty@spd.dsccc.com (Mike McCarty)
- Newsgroups: comp.lang.c
- Subject: Re: Watch out! C "gotcha!"
- Date: 15 Feb 1996 19:34:52 GMT
- Organization: DSC Communications Corporation, Plano, Texas USA
- Message-ID: <4g01ss$hgj@sun001.spd.dsccc.com>
- References: <4fthhh$7th@blackice.winternet.com>
- NNTP-Posting-Host: aplo139.spd.dsccc.com
-
- In article <4fthhh$7th@blackice.winternet.com>,
- Michael Schwarz <mschwarz@winternet.com> wrote:
- )Many of you may already know this, but even after ten years of coding
- )in C, this took my by surprise at first. A co-worker and I were looking
- )at some library C code where I work and we noticed that the "default"
- )clause of one of the switches was misspelled as "defalt."
- )
- )He said, "This must have been changed since it was last compiled."
- )
- )"What the heck, we're in development. Run make."
-
- [stuff cut]
-
- )The thing that scares me the most about this is that either I've never before
- )made this particular mistake or for the last ten years I've been leaving
- )behind a number of ticking code bombs...
-
- I know of no way to make a compiler catch spelling mistakes on labels
- except by doing what Pascal does - force declaration of labels. The
- exact same problem (only worse) occurs in Fortran where misspelled
- variables "declare themselves". There is no solution except to require
- declarations.
-
- This is C. C is a warty, ugly language. The best you can do is learn to
- live with it, or move on to better languages. In this case, learning to
- live with C includes doing careful code inspections. Add looking for
- misspelled labels to your list of things to look for during inspection.
-
- Mike
-
- ----
- char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
-
- I don't speak for DSC. <- They make me say that.
-